<template>
	<view>
		<view class="top-box">
			{{poolInfo && poolInfo.day}}：预消费{{((poolInfo && poolInfo.yxf)*(poolInfo && poolInfo.performance)).toFixed(2) || 0}}<text>/预消费{{((poolInfo && poolInfo.gxz)*(poolInfo && poolInfo.performance)).toFixed(2) || 0}}</text>丨共{{rankList.length}}人参加
		</view>
		<view class="rank-box">
			<view class="flex align-center rank-item" style="margin: 40rpx 30rpx" v-if="rankInfo && rankInfo.userId">
				<view class="myself">我</view>
				<view class="flex align-center justify-center" style="width: 17%;">
					<text class="font-16 text-bold text-theme"
						>{{rankInfo.ranking}}</text>
				</view>
				<view class="flex align-center" style="width: 23%;">
					<view>
						<view class="font-14 text-cut text-bold" style="width: 180rpx;">{{rankInfo.userName}}</view>
						<view class="font-11 text-cut" style="width: 180rpx">ID：{{rankInfo.userId}}</view>
					</view>
				</view>
				<view class="font-14 text-center text-bold flex-sub">{{rankInfo.performancePercent}}%</view>
				<view class="font-14 text-center text-bold flex-sub">{{(rankInfo.money *poolInfo.yxf).toFixed(2) || 0}}</view>
				<view class="font-14 text-center text-bold flex-sub">{{(rankInfo.money *poolInfo.gxz).toFixed(2) || 0}}</view>
			</view>
			<view class="flex text-center padding-lr-sm list-title" style="margin-top: 40rpx;">
				<view style="width: 17%;">排名</view>
				<view style="width: 23%;">用户信息</view>
				<view class="flex-sub">业绩占比</view>
				<view class="flex-sub">预消费</view>
				<view class="flex-sub">贡献值</view>
			</view>
			<view class="flex align-center rank-item" v-for="(item, index) in rankList" :key="index">
				<view class="myself" v-if="userInfo.userId == item.userId">我</view>
				<view class="flex align-center justify-center" style="width: 17%;">
					<image src="/static/my/pool/rank1.png" class="img-64"
						v-if="index ==0"></image>
					<image src="/static/my/pool/rank2.png" class="img-64"
						v-if="index == 1"></image>
					<image src="/static/my/pool/rank3.png" class="img-64"
						v-if="index ==2"></image>
					<text class="font-16 text-bold text-theme"
						v-if="index > 2">{{item.ranking}}</text>
				</view>
				<view class="flex align-center" style="width: 23%;">
					<view>
						<view class="font-14 text-cut text-bold" style="width: 180rpx;">{{item.userName}}</view>
						<view class="font-11 text-cut" style="width: 180rpx">ID：{{item.userId}}</view>
					</view>
				</view>
				<view class="font-14 text-center text-bold flex-sub">{{item.performancePercent}}%</view>
				<view class="font-14 text-center text-bold flex-sub">{{(item.money *poolInfo.yxf).toFixed(2) || 0}}</view>
				<view class="font-14 text-center text-bold flex-sub">{{(item.money *poolInfo.gxz).toFixed(2) || 0}}</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		poolRanking
	} from '@/common/api/customer.js'
	import { mapState } from 'vuex'
	export default {
		data() {
			return {
				background: {
					backgroundColor: '#E60000',
				},
				rankList: [],
				bunusId: '',
				poolInfo: {},
				rankInfo: {},
				current: 0
			};
		},
		computed: {
			...mapState('user', ['userInfo'])
		},
		onLoad(options) {
			this.bunusId = options.bunusId
			this.current = options.current
			this.poolInfo = JSON.parse(options.poolInfo)
			this.getRankInfo()
		},
		methods: {
			getRankInfo() {
				poolRanking(this.bunusId).then(res => {
					this.rankList = res.data && res.data.teams || []
					this.rankInfo = res.data && res.data.user || {}
				})
			}
		}
	}
</script>

<style lang="scss">
	page {
		background: #F2F3F5;
	}
</style>
<style lang="scss" scoped>
	.top-box {
		background: #FA3121;
		border-radius: 8rpx;
		font-size: 26rpx;
		font-weight: bold;
		color: #ffffff;
		margin: 40rpx 30rpx 20rpx 30rpx;
		display: flex;
		justify-content: center;
		align-items: center;
		padding: 20rpx;
	}

	.main-top {
		height: 312rpx;
		border-radius: 15rpx;
		background-image: url('/static/my/pool/pool-bg1.png');
		background-size: 100% 100%;
		background-repeat: no-repeat;
		margin: 0 auto;
		text-align: center;

		.title {
			color: #550A00;
		}

		.people {
			color: #97000B;
			font-size: 32rpx;
		}
	}

	.rank-box {
		.list-title {
			color: #333333;
			font-size: 30rpx;
		}

		.rank-item {
			margin: 20rpx 30rpx 0 30rpx;
			height: 102rpx;
			background: #ffffff;
			border-radius: 16rpx;
			position: relative;
			color: #550A00;

			.avatar {
				width: 77rpx;
				height: 77rpx;
				border-radius: 50%;
			}

			.myself {
				position: absolute;
				top: 0;
				left: 0;
				width: 64rpx;
				height: 30rpx;
				background: #550A00;
				border-radius: 16rpx 0 16rpx 0;
				font-size: 22rpx;
				color: #ffffff;
				display: flex;
				justify-content: center;
				align-items: center;
			}
		}
	}
</style>